﻿<%@ Page Language="C#" AutoEventWireup="true" CodeFile="ClientsCreateEdit.aspx.cs"
    Inherits="ClientsCreateEdit" MasterPageFile="~/Site.master" %>

<%@ Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="asp" %>
<asp:Content ID="BodyContent" runat="server" ContentPlaceHolderID="MainContent">
    <br />
    <asp:ScriptManager ID="ScriptManager1" runat="server">
    </asp:ScriptManager>
    <asp:HyperLink ID="OperatorsLink" runat="server" NavigateUrl="~/Operator/OperatorPanel.aspx">Панель оперетора</asp:HyperLink>&nbsp;→&nbsp;<asp:HyperLink
        ID="HyperLink1" runat="server" NavigateUrl="~/Operator/Clients.aspx">Клиенты</asp:HyperLink>&nbsp;→&nbsp;<asp:Label
            ID="Label1" runat="server" Text="Label" ForeColor="black" Font-Bold="true">Добавление/Редактирование клиента</asp:Label>
    <br />
    <br />
    <table>
        <tr>
            <td class="style1">
                <asp:Label ID="CompanyNameLabel" runat="server" Text="Название предприятия"></asp:Label>
            </td>
            <td>
                <asp:TextBox ID="CompanyName" MaxLength="50" runat="server" OnTextChanged="CompanyName_TextChanged"
                    AutoPostBack="true"></asp:TextBox>
                <asp:AutoCompleteExtender ID="AutoCompleteExtender1" runat="server" TargetControlID="CompanyName"
                    MinimumPrefixLength="1" CompletionInterval="10" CompletionSetCount="3" UseContextKey="True"
                    ServiceMethod="GetCompletionList" DelimiterCharacters="" Enabled="True" ServicePath="">
                </asp:AutoCompleteExtender>
                <asp:RequiredFieldValidator ID="CompanyNameRequired" runat="server" ControlToValidate="CompanyName"
                    CssClass="failureNotification" ToolTip="Company name is not valid" Visible="true"
                    ValidationGroup="RegisterUserValidationGroup">*</asp:RequiredFieldValidator>
                <asp:RegularExpressionValidator runat="server" ID="CompanyNameRequired2" ControlToValidate="CompanyName" Text="Введите название от 2 до 50 )" ForeColor="Red" ValidationExpression="^([a-zA-ZА-Яа-я0-9 '-_&,().]{2,50})+$" ValidationGroup="RegisterUserValidationGroup"/>
         
            </td>
        </tr>
        <tr>
            <td class="style1">
                <asp:Label ID="OrganizationFormLabel" runat="server" Text="Организационная форма"></asp:Label>
            </td>
            <td>
                <asp:DropDownList  ID="OrganizationForm" Width="154px" runat="server" DataSourceID="SqlDataSourceActivity"
                    DataTextField="Name" DataValueField="CompanyOrganizationalFormId" Enabled="false">
                </asp:DropDownList>
                <asp:SqlDataSource ID="SqlDataSourceActivity" runat="server" ConnectionString="<%$ConnectionStrings:DatabaseConnectionString%>"
                    SelectCommand="SELECT [CompanyOrganizationalFormId], [Name] FROM [OrganizationalForm]">
                </asp:SqlDataSource>
            </td>
        </tr>
        <tr>
            <td class="style1">
                <asp:Label ID="CompanySizeLabel" runat="server" Text="Размер предприятия"></asp:Label>
            </td>
            <td>
                <asp:DropDownList ID="CompanySizeList" Width="154px" runat="server" DataSourceID="SqlDataSourceCompanySize"
                    DataTextField="Name" DataValueField="CompanySizeId" Enabled="false">
                </asp:DropDownList>
                <asp:SqlDataSource ID="SqlDataSourceCompanySize" runat="server" ConnectionString="<%$ ConnectionStrings:DatabaseConnectionString %>"
                    SelectCommand="SELECT [Name], [CompanySizeId] FROM [CompanySize]"></asp:SqlDataSource>
            </td>
        </tr>
        <tr>
            <td class="style1">
                <asp:Label ID="ActivityLabel" runat="server" Text="Вид деятельности"></asp:Label>
            </td>
            <td>
                <asp:TextBox ID="Activity" runat="server" Enabled="false" AutoPostBack="true"></asp:TextBox>
                <asp:RequiredFieldValidator ID="ActivityValidator" runat="server" ControlToValidate="Activity"
                    CssClass="failureNotification" ValidationGroup="RegisterUserValidationGroup">*</asp:RequiredFieldValidator>
            </td>
        </tr>
        <tr>
            <td class="style1">
                <asp:Label ID="CreationDateLabel" runat="server" Text="Дата создания"></asp:Label>
            </td>
            <td>
                <asp:TextBox ID="CreationDate" MaxLength="10" runat="server" Enabled="false" AutoPostBack="true"></asp:TextBox>
                <asp:RequiredFieldValidator ID="CreationDateValidator" runat="server" ControlToValidate="CreationDate"
                    CssClass="failureNotification" ValidationGroup="RegisterUserValidationGroup">*</asp:RequiredFieldValidator>
                
                <asp:RegularExpressionValidator ID="CreationDateValidator2" ControlToValidate="CreationDate"
                    Text="Введите в формате DD/MM/YYYY" ForeColor="Red" ValidationExpression="(0[1-9]|[12][0-9]|3[01])[- /.](0[1-9]|1[012])[- /.](19|20)\d\d"
                    runat="server" ValidationGroup="RegisterUserValidationGroup" />

            </td>
        </tr>
        <tr>
            <td class="style1">
                <asp:Label ID="HeadNameLabel" runat="server" Text="Ф.И.О. руководителя"></asp:Label>
            </td>
            <td>
                <asp:TextBox ID="HeadName" MaxLength="50" runat="server"></asp:TextBox>
                <asp:RequiredFieldValidator ID="HeadNameValidator" runat="server" ControlToValidate="HeadName"
                    CssClass="failureNotification" ValidationGroup="RegisterUserValidationGroup">*</asp:RequiredFieldValidator>
                 <asp:RegularExpressionValidator ID="HeadNameValidator2" ControlToValidate="HeadName"
                    Text="Неправильный формат записи ФИО" ForeColor="Red" ValidationExpression="^[А-ЯЁ][а-яё]{1,}(([ ]|[-])([А-ЯЁ]|[а-яё]){1}[а-яё]{1,})*$"
                    runat="server" ValidationGroup="RegisterUserValidationGroup" />

            </td>
        </tr>
        <tr>
            <td class="style1">
                <asp:Label ID="Label2" runat="server" Text="Телефон руководителя"></asp:Label>
            </td>
            <td>
                <asp:TextBox ID="HeadPhone" MaxLength="12" runat="server"></asp:TextBox>
                <asp:RequiredFieldValidator ID="HeadPhoneValidator" runat="server" ControlToValidate="HeadPhone"
                    CssClass="failureNotification" ValidationGroup="RegisterUserValidationGroup">*</asp:RequiredFieldValidator>

                <asp:RegularExpressionValidator ID="HeadPhoneValidator2" ControlToValidate="HeadPhone"
                    Text="Неправильный формат тел. номера" ForeColor="Red" Display="Dynamic" ValidationExpression="[1-9]{1}[0-9]{6,12}"
                    runat="server" ValidationGroup="RegisterUserValidationGroup" Font-Bold="False" />

            </td>
        </tr>
        <tr>
            <td class="style1">
                <asp:Label ID="Label3" runat="server" Text="Адрес руководителя"></asp:Label>
            </td>
            <td>
                <asp:TextBox ID="HeadAddress" MaxLength="50"  runat="server"></asp:TextBox>
                <asp:RequiredFieldValidator ID="HeadAddressValidator" runat="server" ControlToValidate="HeadAddress"
                    CssClass="failureNotification" ValidationGroup="RegisterUserValidationGroup">*</asp:RequiredFieldValidator>

                  <asp:RegularExpressionValidator ID="HeadAdressValidator1" ControlToValidate="HeadAddress"
                    Text="Неправильный формат записи адреса (7-100)" ForeColor="Red" Display="Dynamic" ValidationExpression="^([a-zA-ZА-ЯЁа-яё0-9 !'-_&,().]{7,50})+$"
                    runat="server" ValidationGroup="RegisterUserValidationGroup" />
            </td>
        </tr>
        <tr>
            <td class="style1">
                <asp:Label ID="CompanyHeadEmailLabel" runat="server" Text="Email руководителя"></asp:Label>
            </td>
            <td>
                <asp:TextBox ID="CompanyHeadEmail" runat="server"></asp:TextBox>
                <asp:RequiredFieldValidator ID="CompanyHeadEmailValidator" runat="server" ControlToValidate="CompanyHeadEmail"
                    CssClass="failureNotification" Visible="true" ValidationGroup="RegisterUserValidationGroup">*</asp:RequiredFieldValidator>
                <asp:RegularExpressionValidator ID="CompanyHedEmailValidator2" ControlToValidate="CompanyHeadEmail"
                    Text="Неправильный формат записи Email." ForeColor="Red" ValidationExpression="^[-\w.]+@([A-z0-9][-A-z0-9]+\.)+[A-z]{2,4}$"
                    runat="server" ValidationGroup="RegisterUserValidationGroup" />
            </td>
        </tr>
        <tr>
            <td class="style1">
                <asp:Label ID="CompanyAddressLabel" runat="server" Text="Адрес предприятия"></asp:Label>
            </td>
            <td>
                <asp:TextBox ID="CompanyAddress" MaxLength="100" runat="server"></asp:TextBox>
                <asp:RequiredFieldValidator ID="CompanyAddressValidator" runat="server" ControlToValidate="CompanyAddress"
                    CssClass="failureNotification" ValidationGroup="RegisterUserValidationGroup">*</asp:RequiredFieldValidator>
                   <asp:RegularExpressionValidator ID="CompanyAdressValidator1" ControlToValidate="CompanyAddress"
                    Text="Неправильный формат записи адреса (7-100)" ForeColor="Red" Display="Dynamic" ValidationExpression="^([a-zA-ZА-ЯЁа-яё0-9 !'-_&,().]{7,50})+$"
                    runat="server" ValidationGroup="RegisterUserValidationGroup" />

            </td>
        </tr>
        <tr>
            <td class="style1">
                <asp:Label ID="CompanyPhoneLabel" runat="server" Text="Телефон предприятия"></asp:Label>
            </td>
            <td>
                <asp:TextBox ID="CompanyPhone" MaxLength="12" runat="server"></asp:TextBox>
                <asp:RequiredFieldValidator ID="CompanyPhoneValidator" runat="server" ControlToValidate="CompanyPhone"
                    CssClass="failureNotification" ValidationGroup="RegisterUserValidationGroup">*</asp:RequiredFieldValidator>

                <asp:RegularExpressionValidator ID="CompanyPhoneValidator1" ControlToValidate="CompanyPhone"
                    Text="Неправильный формат тел. номера" ForeColor="Red" Display="Dynamic" ValidationExpression="[1-9]{1}[0-9]{6,12}"
                    runat="server" ValidationGroup="RegisterUserValidationGroup" Font-Bold="False" />

            </td>
        </tr>
        <tr>
            <td class="style1">
                <asp:Label ID="CompanyEmailLabel" runat="server" Text="Email предприятия"></asp:Label>
            </td>
            <td>
                <asp:TextBox ID="CompanyEmail" MaxLength="30"  runat="server" Width="148px"></asp:TextBox>
                <asp:RequiredFieldValidator ID="CompanyEmailValidator" runat="server" ControlToValidate="CompanyEmail"
                    CssClass="failureNotification" ValidationGroup="RegisterUserValidationGroup">*</asp:RequiredFieldValidator>
                <asp:RegularExpressionValidator ID="regEmail" ControlToValidate="CompanyEmail" Text="(Invalid email)"
                    ValidationExpression="\w+([-+.']\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*" runat="server"
                    ValidationGroup="RegisterUserValidationGroup" />
            </td>
        </tr>
        <tr>
            <td class="style1">
                <asp:Label ID="LoginLabel" runat="server" Text="Логин"></asp:Label>
            </td>
            <td>
                <asp:TextBox Width="148px" ID="Login" MaxLength="20" runat="server"></asp:TextBox>
                <asp:RequiredFieldValidator ID="LoginValidator" runat="server" ControlToValidate="Login"
                    CssClass="failureNotification" ValidationGroup="RegisterUserValidationGroup">*</asp:RequiredFieldValidator>
                        <asp:RegularExpressionValidator runat="server" ID="LoginValidator2" ControlToValidate="Login"
                Display="Dynamic" Text="Имя пользователя сост. 2-20 лат. букв и цифры, 1-й символ буква!"
                ForeColor="Red" ValidationExpression="^[a-zA-Z][a-zA-Z0-9-_\.]{1,20}$" ValidationGroup="RegisterUserValidationGroup" />
            </td>
            <td>
                <asp:Button ID="GenerateLoginButton" runat="server" Text="Генерировать логин" Width="172px"
                    OnClick="GenerateLoginButton_Click" />
            </td>
        </tr>
        <tr>
            <td class="style1">
                <asp:Label ID="PasswordLabel" runat="server" Text="Пароль"></asp:Label>
            </td>
            <td>
                <asp:TextBox ID="Password"  MaxLength="20" runat="server"></asp:TextBox>
                <asp:RequiredFieldValidator ID="PasswordValidator" runat="server" ControlToValidate="Password"
                    CssClass="failureNotification" ValidationGroup="RegisterUserValidationGroup" Enabled="false" >*</asp:RequiredFieldValidator>
                  <asp:RegularExpressionValidator ID="OperatorPasswordValidator2" ControlToValidate="Password" Enabled="false"
                Text="Пароль должен состоять из цифр и букв латинского алфавита (6,20)" ForeColor="Red"
                ValidationExpression="(?!^[0-9]*$)(?!^[a-zA-Z]*$)^([a-zA-Z0-9]{6,20})$" runat="server"
                ValidationGroup="RegisterUserValidationGroup" />
            </td>
            <td>
                <asp:Button ID="ResetPassword" runat="server" Text="Генерировать пароль" OnClick="ResetPassword_Click"
                    Width="172px" />
            </td>
        </tr>
        <tr>
            <td class="style1">
                <asp:Label ID="CompanyProfitLabel" runat="server" Text="Доход предприятия за последние 2 года (или мение, если предприятие существует меньше 2-ух лет)"></asp:Label>
            </td>
            <td>
                <asp:TextBox ID="CompanyProfit" runat="server"></asp:TextBox>
                <asp:RequiredFieldValidator ID="CompanyProfitValidator" runat="server" ControlToValidate="CompanyProfit"
                    CssClass="failureNotification" ValidationGroup="RegisterUserValidationGroup">*</asp:RequiredFieldValidator>
                   <asp:RegularExpressionValidator ID="CompanyProfitValidator1" ControlToValidate="CompanyProfit"
                    Text="Введите целое положительное число" ForeColor="Red" Display="Dynamic" ValidationExpression="[1-9]{1}[0-9]{1,12}"
                    runat="server" ValidationGroup="RegisterUserValidationGroup" Font-Bold="False" />

            </td>
        </tr>
        <tr>
            <td class="style1">
                <asp:Label ID="HaveCreditLabel" runat="server" Text="Наличие кредитов"></asp:Label>
            </td>
            <td>
                <asp:CheckBox ID="HaveCredit" runat="server" />
            </td>
        </tr>
    </table>
    <br />
    <asp:Button ID="RegisterUserButton" runat="server" Text="Зарегистрировать" OnClick="RegisterUserButton_Click"
        ValidationGroup="RegisterUserValidationGroup" />
    <asp:Label ID="ErrorLabel" runat="server" Text=""></asp:Label>
    <br />
</asp:Content>
<asp:Content ID="Content1" runat="server" ContentPlaceHolderID="HeadContent">
    <style type="text/css">
        .style1
        {
            width: 286px;
        }
    </style>
</asp:Content>
